#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main() {
	int date, second, third;
	scanf("%d%d%d", &date,&second,&third);
	third %= 10;
	if (date <= 0 || date > 7) {
		printf("date error");
		return 1;
	}
	if (date==6||date==7) {
		printf("%d no\n", third);
		return 0;
	}
	if (date <= 5 && date > 0)
	{
		if (second < 0) {
			printf("deta error");
			return 1;
		}
		if (second >= 0 && second < 200) {
			printf("%d no\n", third);
			return 0;
		}
		if (second >= 200 && second < 400)
		{
			int isLimited = 0;
			switch (date)
			{
			case 1:if (third == 1 || third == 6) { isLimited = 1; }break;
			case 2:if (third == 2 || third == 7) { isLimited = 1; }break;
			case 3:if (third == 3 || third == 8) { isLimited = 1; }break;
			case 4:if (third == 4 || third == 9) { isLimited = 1; }break;
			case 5:if (third == 5 || third == 0) { isLimited = 1; }break;
			}
			if (isLimited) { printf("%d yes\n", third); }
			else { printf("%d no\n", third); }
		}
		else if (second >= 400)
		{
			int isLimited = 0;
			switch (date)
			{
			case 1:if (third == 1 || third == 3 || third == 5 || third == 7 || third == 9) { isLimited = 1; }break;
			case 2:if (third == 2 || third == 4 || third == 6 || third == 8 || third == 0) { isLimited = 1; }break;
			case 3:if (third == 1 || third == 3 || third == 5 || third == 7 || third == 9) { isLimited = 1; }break;
			case 4:if (third == 2 || third == 4 || third == 6 || third == 8 || third == 0) { isLimited = 1; }break;
			case 5:if (third == 1 || third == 3 || third == 5 || third == 7 || third == 9) { isLimited = 1; }break;
			}
			if (isLimited) { printf("%d yes\n", third); }
			else { printf("%d no\n", third); }
		}
	}
	return 0;
}